﻿package mortal.game.view.common.cd.effect
{
    import flash.display.*;
    import flash.events.*;
    import mortal.common.pools.*;

    public class CDFreezingEffect extends ItemCD implements ICDEffect
    {
        private var _maskBitmap:Bitmap;
        private var _registed:Boolean = false;

        public function CDFreezingEffect()
        {
            mouseChildren = false;
            mouseEnabled = false;
            return;
        }// end function

        public function set registed(param1:Boolean) : void
        {
            this._registed = param1;
            return;
        }// end function

        public function get registed() : Boolean
        {
            return this._registed;
        }// end function

        public function setMaskSize(param1:Number, param2:Number) : void
        {
            if (this._maskBitmap == null)
            {
                this._maskBitmap = new Bitmap();
            }
            if (this._maskBitmap.width != param1 || this._maskBitmap.height != param2)
            {
                this._maskBitmap.bitmapData = BitmapDataPool.getMaskBitmapData(param1, param2);
            }
            this._maskBitmap.x = (-param1) / 2;
            this._maskBitmap.y = (-param2) / 2;
            this.addChild(this._maskBitmap);
            this.mask = this._maskBitmap;
            return;
        }// end function

        public function onTimer(param1:int) : void
        {
            this.gotoAndStop((param1 + 1));
            if (param1 > 100)
            {
                this.reset();
                this.dispatchEvent(new Event(Event.COMPLETE));
            }
            return;
        }// end function

        public function get cdEffectTimerType() : String
        {
            return CDEffectTimerType.Percentage;
        }// end function

        public function reset() : void
        {
            this.gotoAndStop(1);
            return;
        }// end function

    }
}
